import {HttpProvider, AjaxOption} from '../../common/http'
import {Injectable} from '@angular/core';
import {API} from "../../common/api";
import {Helper} from "../../common/Helper";

@Injectable()
export class UserProvider {

  constructor(public http: HttpProvider,
              public helper: Helper) {

  }

  getUserInfo(options: AjaxOption) {
    return this.http.ajax({
      type: 'GET',
      url: API.ACCOUNT_INDEX,
      options: options
    })
  }

  authName(options: AjaxOption) {
    this.helper.loading('认证中..')
    return this.http.ajax({
      type: 'POST',
      url: API.USER_AUTH_NAME,
      options: options
    })
  }

  getAuthStatus(options: AjaxOption) {
    return this.http.ajax({
      type: 'GET',
      url: API.ACCOUNT_AUTH_BIND,
      options: options
    })
  }

  getBankList(options: AjaxOption) {
    this.helper.loading('加载中..')
    return this.http.ajax({
      type: 'GET',
      url: API.ACCOUNT_GET_BANK_CARD,
      options: options
    })
  }

  addBankCard(options: AjaxOption) {
    this.helper.loading('绑定中..')
    return this.http.ajax({
      type: 'POST',
      url: API.ACCOUNT_BIND_BANK_CARD,
      options: options
    })
  }

  removeBankCard(options: AjaxOption) {
    return this.http.ajax({
      type: 'POST',
      url: API.ACCOUNT_DELETE_BANK_CARD,
      options: options
    })
  }

  setPayPassword(options: AjaxOption) {
    this.helper.loading('请稍后..')
    return this.http.ajax({
      type: 'POST',
      url: API.USER_SET_PAY_PASSWORD,
      options: options
    })
  }

  getAccountDetail(options: AjaxOption) {
    return this.http.ajax({
      type: 'GET',
      url: API.ACCOUNT_DETAIL,
      options: options
    })
  }

  getInvest(options: AjaxOption) {
    return this.http.ajax({
      type: 'GET',
      url: API.INVEST_MY_INVEST,
      options: options
    })
  }

  getInvestFinish(options: AjaxOption) {
    return this.http.ajax({
      type: 'GET',
      url: API.INVEST_MY_INVEST_FINISH,
      options: options
    })
  }

  setLoginPassword(options: AjaxOption) {
    this.helper.loading('提交中..')
    return this.http.ajax({
      type: 'POST',
      url: API.USER_MODIFY_PSW,
      options: options
    })
  }

}
